<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    div{
        width:100px;
        height:100px;
        background-color:pink
    }
</style>
<body>
    <div>1</div>
    <div>2</div>
    <div>3</div>
    <script>
        //1、传统事件的移除 onclick = null
        var divs = document.querySelectorAll('div');
        divs[0].onclick = function(){
            alert('hello')
            divs[0].onclick = null;
        }

        //2、removeEventListener('type',listener,useCapture)
        divs[1].addEventListener('click',fun);
        function fun(){
            alert('world')
            divs[1].removeEventListener('click',fun)
        }
       

    </script>
</body>
</html>